$(function () {
  $.ajax({
    url: "http://chst.vip:1234/api/getcategorytitle",
    success: (res1) => {
      let htm = "";
      $.each(res1.result, (i1, item1) => {
        $.ajax({
          url: `http://chst.vip:1234/api/getcategory?titleid=${item1.titleId}`,
          success: (res2) => {
            let htm2 = "";
            $.each(res2.result, (i2, item2) => {
              htm2 += `
          <a href='bijia.html?title=${item2.category}&amp;categoryid=${item2.categoryId}'>${item2.category}</a>
          `;
            });
            $(`.detail${i1}`).html(htm2);
          },
        });
        htm += `
      <li titleId='${item1.titleId}'>
          <span>${item1.title}<b>▼</b></span>
          <div class='detail${i1}'>
          </div>
      </li>
      `;
      });
      $("ul").html(htm);
      $(".main li div").hide().css("height", "100%");
      $(".main li span").click(function () {
        $(this).next().slideToggle(200).end().children("b").text("▲");
      });
    },
  });
});
